<%@page import="com.entity.Project"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>新建目标</title>

</head>
<body>

	<%
		List<Employee> employees=(List<Employee>)request.getAttribute("employees");
	 %>
	
	<div class="container well" style="width:800px">
		<h1>新建目标</h1>
		
		<div>
			<form id="form" action="addgoal.jspx" method="post" class="form-horizontal well">
						<div class="form-inline">
							<label>目标名称</label><br>
							<input id="input01" style="height:30px" type="text" class="input-xlarge" placeholder="请输入目标名称" name = "goalName">
							 <span style="color:red" id="input01_msg"></span>
						</div>
						
						<br /><br />
						<label>目标描述</label>
						<textarea  rows="3" id="input02" class="span7"  placeholder="请输入目标的描述" name = "goalDesc"></textarea>
						 <span style="color:red" id="input02_msg"></span>
						<br /><br />
						<label>负责人</label>
						
						<select id="input03" name="goalAdmin">
							<option value="">-请选择目标负责人-</option>
							<%
								for(Employee e:employees){
								
							%>
								<option value="<%=e.getId()%>"><%=e.getUsername() %></option>
							<%
								}
							%>
						</select>
						 <span style="color:red" id="input03_msg"></span>
						<br /><br />
				
						<div class="form-actions">
							<button class="btn btn-primary" type="submit">保存目标</button>
							<a class="btn" href="goal.jspx">取消</a>
						</div>
				
			</form>
		</div>
	</div>
	<script type="text/javascript">
		document.getElementById("form").onsubmit=function(){
			
			var input01 = document.getElementById("input01").value;
			var input02 = document.getElementById("input02").value;
			var input03 = document.getElementById("input03").value;
			
			if(input01.trim() == "") {
				document.getElementById("input01_msg").innerHTML = "请输入目标名称";
				document.getElementById("input01").focus();
				return false;
			}
				if(input02.trim() == "") {
				
				document.getElementById("input02_msg").innerHTML = "请输入目标描述";
				document.getElementById("input02").focus();
				return false;
			}
				if(input03 == "") {
				
				document.getElementById("input03_msg").innerHTML = "请选择目标负责人";
				document.getElementById("input03").focus();
				return false;
			}
			
		};
		
		document.getElementById("input01").onblur = function(){
		
			var input01 = document.getElementById("input01").value;
			if(input01.trim() == "") {
				document.getElementById("input01").value = "";
				document.getElementById("input01_msg").innerHTML = "请输入目标名称";
				document.getElementById("input01").focus();
			}else{
				document.getElementById("input01_msg").innerHTML = "";
			}
		};
		document.getElementById("input02").onblur = function(){
		
			var input02 = document.getElementById("input02").value;
			if(input02.trim() == "") {
				document.getElementById("input02").value = "";
				document.getElementById("input02_msg").innerHTML = "请输入目标";
				document.getElementById("input02").focus();
			}else{
				document.getElementById("input02_msg").innerHTML = "";
			}
		};
		document.getElementById("input03").onblur = function(){
		
			var input03 = document.getElementById("input03").value;
			if(input03 == "") {
				document.getElementById("input03").value = "";
				document.getElementById("input03_msg").innerHTML = "请选择目标负责人";
				document.getElementById("input03").focus();
			}else{
				document.getElementById("input03_msg").innerHTML = "";
			}
		};
		
		document.getElementById("input01").onkeydown = function(){
			document.getElementById("input01_msg").innerHTML = "";
		};
		document.getElementById("input02").onkeydown = function(){
			document.getElementById("input02_msg").innerHTML = "";
		};
		document.getElementById("input03").onchange= function(){
			document.getElementById("input03_msg").innerHTML = "";
		};
	</script>
</body>
</html>